<?php ob_start();session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
} ?>
<!DOCTYPE HTML>
<html><head>
	<title>Price Checking</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 	<link href="css/default.css" rel="stylesheet" type="text/css">
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<script>
	function checklogin()
	{
		nn=document.n;
		if(nn.aid.value=="")
		{
			alert("Fill in Username");
			nn.adi.focus();
			return;
		}
		if(nn.apw.value=="")
		{
			alert("Fill in Password");
			nn.apw.focus();
			return;
		}
		nn.submit();
	}
</script>
<style>
.login{-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; background:#0cf; color:#fff; font-size:14px; border: 0; }
.login:hover{background:#09f; cursor:pointer; }
table input{
    border: 1px solid #848484; 
    -webkit-border-radius: 5px; 
    -moz-border-radius: 5px; 
    border-radius: 5px; 
    padding-left:10px;
  } 
</style>
<body>
<?php
	include "connection_open.php";
	if(isset($_REQUEST['login']))
	{
		$user=$_REQUEST['aid'];
		$pass=md5($_REQUEST['apw']);
		$query=@mysql_query("select * from admin where username='$user' and password='$pass'");
		if(@mysql_num_rows($query)==0)
		{
			echo "<script>alert('Account infomation not exactly')</script>";
		}
		else
		{
			$r=mysql_fetch_array($query);
			session_start();
			$mang=array($r['id'],$r['username'],$r['role']);
			$_SESSION['accountshopping']=$mang;
			header("Location: index.php");
			//setcookie('accountshopping',$_SESSION['accountshopping'],time()+3600*24);
		}
	}

	include "connection_close.php";
?>
<?php if(!isset($_SESSION['accountshopping'])) { ?>
<div style="text-align:center;">
			<div class="login_area" style="border:0px red solid; margin:30px auto;">
				<div style="margin:0px auto; text-align:center;"><img src="img/login_img.png" width="200px"></div>
				<div id="DivloginSoho" >
					<form name="n" id="n" method="POST" action="login.php">
					<table cellspacing="0" cellpadding="3" border="0" style="margin:10px auto;">
						<colgroup>
							<col width="300px">
						</colgroup>
						<tbody>
							<tr>
								<td>
									<div class="contBox"><input id="aid" name="aid" type="text" value="" autocomplete="off"></div>
								</td>
							</tr>
							<tr>
								<td>
									<div class="contBox"><input id="apw" name="apw" type="password" value="" autocomplete="off"></div>
								</td>
							</tr>
						</tbody>
						<tfoot>
							<tr>
								<td><input type="button" class="login" style="height:30px;width:323px;" name="login" value="Sign In" onclick="checklogin()" /></td>
								<input type="hidden" name="login" />
							</tr>
						</tfoot>
					</table>
					</form>
				</div>
			</div>

</div>
<?php } else { header("Location: ../checkshop"); } ?>
</body>
</html>
